import request from '@/utils/request'

const commonUrl="/admin/product/baseTrademark"

//获取所有的品牌信息 GET /admin/product/baseTrademark/getTrademarkList
export function getAllTrademark() {
  return request({
    url: `${commonUrl}/getTrademarkList`,
    method: 'get'
  })
}

//分页查询: GET /admin/product/baseTrademark/{page}/{limit}
export async function getBaseTrademark({page,limit}) {
  const {code,data} = await request({
    url: `${commonUrl}/${page}/${limit}`,
    method: 'get'
  })
  return {code,data}
}

//新增品牌: POST /admin/product/baseTrademark/save
export function addBaseTrademark({logoUrl,tmName}) {
  return request({
    url: `${commonUrl}/save`,
    method: 'post',
    data:{
      logoUrl,
      tmName
    }
  })
}

//修改品牌: PUT /admin/product/baseTrademark/update
export function updateBaseTrademark({id,logoUrl,tmName}) {
  return request({
    url: `${commonUrl}/update`,
    method: 'put',
    data:{
      id,
      logoUrl,
      tmName
    }
  })
}

//新增&修改的请求
export function addOrUpdate({id,logoUrl,tmName}){
  if(id)
    return updateBaseTrademark({id,logoUrl,tmName})
  else
    return addBaseTrademark({logoUrl,tmName})
}

//删除品牌: DELETE /admin/product/baseTrademark/remove/{id}
export function deleteBaseTrademark(id) {
  return request({
    url: `${commonUrl}/remove/${id}`,
    method: 'delete'
  })
}
